import Vue from 'vue'
import VueRouter from 'vue-router'

// Vue加载插件的语法
Vue.use(VueRouter)

// 再导出VueRouter实例，这里格式是：VueRouter实例的参数是一个对象
export default new VueRouter({
  // routes(路由):即url输入对应的路径,加载显示对应的组件
  routes: [
    {
      path: '/',
      name: 'home', // 若这里取了name,则对应导入的component组件中也要定义相同的name: 'home'
      component: () => import('./../views/home.vue'),
      redirect: '/index', // 默认输入xxx:8080 跳转到 xxx:8080/index中
      children: [
        {
          // 示例：http://192.168.0.107:8080/index
          path: '/index',
          name: 'index',
          component: () => import('./../views/index.vue')
        },
        {
          // 动态路由(即url中可加参数并获取)：
          // http://192.168.0.107:8080/product/id(一个参数)
          path: '/product/:id',
          name: 'product',
          component: () => import('./../views/product.vue')
        },
        {
          // 动态路由(即可加参数并获取)：
          // http://192.168.0.107:8080/detail/id(一个参数)
          path: '/detail/:id',
          name: 'detail',
          component: () => import('./../views/detail.vue')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('./../views/login.vue')
    },
    {
      path: '/phoneLogin',
      name: 'PhoneLogin',
      component: () => import('./../views/phoneLogin')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import('./../views/Register.vue')
    },
    {
      path: '/cart',
      name: 'cart',
      component: () => import('./../views/cart.vue')
    },
    {
      path: '/personal',
      name: 'cart',
      component: () => import('./../views/personal')
    },
    // {
    //   path: '/insuranceAfterSale',
    //   name: 'insuranceAfterSale',
    //   component: () => import('./../views/insuranceAfterSale')
    // },
    {
      path: '/order',
      name: 'order',
      component: () => import('./../views/order.vue'),
      children: [
        {
          path: '/order/list',
          name: 'order-list',
          component: () => import('./../views/orderList.vue')
        },
        {
          path: '/order/confirm',
          name: 'order-confirm',
          component: () => import('./../views/orderConfirm.vue')
        },
        {
          path: '/order/orderDetial',
          name: 'order-pay',
          component: () => import('./../views/orderDetial')
        },
        {
          path: '/order/pay',
          name: 'order-pay',
          component: () => import('./../views/orderPay.vue')
        },
        {
          path: '/order/alipay',
          name: 'alipay',
          component: () => import('./../views/alipay.vue')
        }
      ]
    },
    {
      path: '/service',
      name: 'service',
      component: () => import('./../views/service'),
      children: [
        {
          path: 'serviceRefund', //退货退款售后
          name: 'insuranceAfterSale',
          component: () => import('./../views/serviceRefund.vue')
        }, {
          path: 'insuranceAfterSale', //保险售后
          name: 'insuranceAfterSale',
          component: () => import('./../views/insuranceAfterSale.vue')
        }, {
          path: 'serviceMaintenance', //维修售后
          name: 'serviceMaintenance',
          component: () => import('./../views/serviceMaintenance.vue')
        }, {
          path: 'serviceExchange', //换货
          name: 'serviceExchange',
          component: () => import('./../views/serviceExchange.vue')
        }, {
          path: 'serviceCategory', //售后分类
          name: 'serviceCategory',
          component: () => import('./../views/serviceCategory.vue')
        },
      ]
    },
    {
      path: '/clientService',
      name: 'customer-service',
      component: () => import('../views/clientService')
    },
    {
      path: '/customerService',
      name: 'customer-service',
      component: () => import('../views/customerService')
    },
    {
      path: '/ServiceList',
      name: 'customer-service',//商家获取订单信息表
      component: () => import('../views/Servicelist')
    },
    {
      path: '/serviceBase', //售后详情
      name: 'serviceBase',
      component: () => import('./../views/serviceBase.vue'),
      children: [
        {
          path: 'serviceDetail', //售后详情
          name: 'serviceDetail',
          component: () => import('./../views/serviceDetail.vue')
        }, {
          path: 'serviceGoods', //售后的商品列表
          name: 'serviceGoods',
          component: () => import('./../views/serviceGoods.vue')
        },
      ]
    },
    {
      path: '/tribunal',
      name: 'tribunal',
      component: ()=> import('./../views/tribunal'),
      children: [
        {
          path: 'tribunalDetail', //法庭记录
          name: 'tribunalDetail',
          component: ()=> import('./../views/tribunalDetail'),
          children: [
            {
              path: 'presentation',
              name: 'presentation',
              component: ()=> import('./../views/presentation')
            },
            {
              path: 'transactionRecords',
              name: 'transactionRecords',
              component: ()=> import('./../views/transactionRecords')
            }
          ]
        },
        {
          path: 'TribunalTab', //我的法庭记录
          name: 'TribunalTab',
          component: ()=> import('./../views/TribunalTab'),
          children: [
            {
              path:'myTribunal',
              name: 'myTribunal',
              component: ()=> import('./../views/myTribunal')
            },
            {
              path:'allTribunal',
              name: 'allTribunal',
              component: ()=> import('./../views/allTribunal')
            }
          ]
        }
      ]
    },
  ]
})
